﻿@model Survery.Website.Areas.Manage.Models.QuestionViewModel

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>QuestionViewModel</h4>
        <hr />
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.Id)

        <input type="hidden" name="SurveryId" value='@Model.SurveryId' />
        <div class="form-group">
            @Html.LabelFor(model => model.SortId, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.SortId)
                @Html.ValidationMessageFor(model => model.SortId)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.QuestionType, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownListFor(model => model.QuestionType, ViewData["QType"] as IEnumerable<SelectListItem>)
                @Html.ValidationMessageFor(model => model.Description)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Description, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Description)
                @Html.ValidationMessageFor(model => model.Description)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.FormName, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.FormName)
                @Html.ValidationMessageFor(model => model.FormName)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Selections, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <p>
                    <input type="text" name="Selections[0].Value" value="@Model.Selections.ElementAt(0).Value" /><input type="text" name="Selections[0].Context" value="@Model.Selections.ElementAt(0).Context" />
                </p>
                <p>
                    <input type="text" name="Selections[1].Value" value="@Model.Selections.ElementAt(1).Value" /><input type="text" name="Selections[1].Context" value="@Model.Selections.ElementAt(1).Context" />
                </p>
                <p>
                    <input type="text" name="Selections[2].Value" value="@Model.Selections.ElementAt(2).Value" /><input type="text" name="Selections[2].Context" value="@Model.Selections.ElementAt(2).Context" />
                </p>
                <p>
                    <input type="text" name="Selections[3].Value" value="@Model.Selections.ElementAt(3).Value" /><input type="text" name="Selections[3].Context" value="@Model.Selections.ElementAt(3).Context" />
                </p>
                <!--TODO:js 转成动态-->
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
